/*
 *  Copyright 2009 Brian Mackay brianwmackay@msn.com
 *   All Rights Reserved. See end of file
 *   Some portions of this class where taken from hadoop JUNIT tests
 */
package com.bmackay.vonsteuben.job.control;

import com.bmackay.vonsteuben.job.mapred.base.JobDrivers;
import java.util.ArrayList;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.jobcontrol.Job;
import org.apache.hadoop.mapred.jobcontrol.JobControl;

public class VonSteubenJobControl {

    public JobControl set(JobDrivers jobDrivers) {

        ArrayList allJobs = new ArrayList<Job>();
        ArrayList<Job> jobs = null;
        JobControl jobControl = new JobControl(jobDrivers.getJobControlName());

        for (int i = 0; i < jobDrivers.get().size(); i++) {
            try {

                JobConf driverConf = jobDrivers.get(i);

                jobs = new ArrayList<Job>();
                for (int ii = 0; ii < allJobs.size(); ii++) {
                    Job depJob = (Job) allJobs.get(ii);
                    jobs.add(depJob);
                }

                Job job = new Job(driverConf, jobs);
                allJobs.add(job);
                jobControl.addJob(job);

            } catch (Exception ex) {
                System.out.print("VonSteubenJobControl:error:" + ex + "\n");
            }
        }

        return jobControl;
    }
}
/*
 * Copyright 2009 Brian Mackay brianwmackay@msn.com
 * All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
